package com.yww.leetcode2.hashtable;

/**
 * @author yww
 * @description 242. 有效的字母异位词
 * @since 2024/11/12
 */
public class IsAnagram242_01 {
    // abc cba bca abc -> true
    public boolean isAnagram(String s, String t) {
        char[] sArr = s.toCharArray();
        char[] tArr = t.toCharArray();
        int[] hashtable = new int[26];
        for (int i = 0; i < sArr.length; i++) {
            hashtable[sArr[i] - 'a']++;
        }
        for (int i = 0; i < tArr.length; i++) {
            hashtable[tArr[i] - 'a']--;
        }
        for (int i = 0; i < hashtable.length; i++) {
            if (hashtable[i] != 0) {
                return false;
            }
        }
        return true;
    }
}
